package org.luxor.commons.schedule.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import org.luxor.commons.core.utils.DateUtils;

import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Date;

/**
 * 定时任务日志
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.2.0 2016-11-28
 */
@TableName("tb_sys_schedule_job_log")
public class ScheduleJobLogEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 日志id
     */
    @TableId(type = IdType.ASSIGN_ID)
    @ApiModelProperty(value = "日志ID")
    private Long id;

    /**
     * 任务id
     */
    @NotBlank(message = "任务id不能为空")
    @ApiModelProperty(value = "定时任务ID")
    private Long jobId;

    /**
     * spring bean名称
     */
    @NotBlank(message = "springBean名称不能为空")
    @ApiModelProperty(value = "springBean名称", example = "cleanLogTask")
    private String beanName;

    /**
     * 方法名
     */
    @NotBlank(message = "方法名不能为空")
    @ApiModelProperty(value = "方法名", example = "run")
    private String methodName;

    /**
     * 参数
     */
    @ApiModelProperty(value = "日参数")
    private String params;

    /**
     * 任务状态    0：成功    1：失败
     */
    @NotBlank(message = "任务状态不能为空")
    @ApiModelProperty(value = "任务状态(0：成功 1：失败)", example = "1")
    private Integer status;

    /**
     * 失败信息
     */
    @ApiModelProperty(value = "失败信息")
    private String error;

    /**
     * 耗时(单位：毫秒)
     */
    @NotBlank(message = "耗时不能为空")
    @ApiModelProperty(value = "耗时(单位：毫秒)")
    private Long times;

    /**
     * 创建时间
     */
    @NotBlank(message = "创建时间不能为空")
    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN, timezone = "GMT+8")
    private Date createTime;

    public ScheduleJobLogEntity() {
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getJobId() {
        return jobId;
    }

    public void setJobId(Long jobId) {
        this.jobId = jobId;
    }

    public String getBeanName() {
        return beanName;
    }

    public void setBeanName(String beanName) {
        this.beanName = beanName;
    }

    public String getMethodName() {
        return methodName;
    }

    public void setMethodName(String methodName) {
        this.methodName = methodName;
    }

    public String getParams() {
        return params;
    }

    public void setParams(String params) {
        this.params = params;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getError() {
        return error;
    }

    public void setError(String error) {
        this.error = error;
    }

    public Long getTimes() {
        return times;
    }

    public void setTimes(Long times) {
        this.times = times;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    @Override
    public String toString() {
        return "ScheduleJobLogEntity{" +
                "id=" + id +
                ", jobId=" + jobId +
                ", beanName='" + beanName + '\'' +
                ", methodName='" + methodName + '\'' +
                ", params='" + params + '\'' +
                ", status=" + status +
                ", error='" + error + '\'' +
                ", times=" + times +
                ", createTime=" + createTime +
                '}';
    }
}
